package edu.hm.risikomanagement;

import edu.hm.risikomanagement.library.DatabaseData;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class RisikenVerwalten extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.risiken_verwalten);
        final Button btn_Neues_Risiko_anlegen = (Button)findViewById(R.id.btn_Neues_Risiko_anlegen);
        final Button btn_Risiko_betrachen_bearbeiten = (Button)findViewById(R.id.btn_Risiko_betrachen_bearbeiten);
        final Button btn_RisikenVerwaltenBack = (Button)findViewById(R.id.btn_RisikenVerwaltenBack);
        
        btn_Neues_Risiko_anlegen.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				
				if (DatabaseData.isNetworkAvailable(getApplicationContext())) {
					Intent i = new Intent(RisikenVerwalten.this, NeuesRisikoAnlegen.class);
			        startActivity(i);
				} else {
					Intent i = new Intent(RisikenVerwalten.this, Error.class);
					i.putExtra("error", getString(R.string.connection_error));
					startActivityForResult(i, 1);
				}	
				
			}
		});
        
        btn_Risiko_betrachen_bearbeiten.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				
						if (DatabaseData
								.isNetworkAvailable(getApplicationContext())) {
							Intent i = new Intent(RisikenVerwalten.this,
									RisikoBetrachtenListe.class);
							startActivity(i);
						} else {
							Intent i = new Intent(RisikenVerwalten.this,
									Error.class);
							i.putExtra("error",
									getString(R.string.connection_error));
							startActivityForResult(i, 1);
						}
				
			}
		});
        
        btn_RisikenVerwaltenBack.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				finish();
			}
		});
		
    }
}